package com.ruoyi.web.controller.datastatistics;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.datastatistics.service.ITerminalsDayfreezeDbService;
import com.ruoyi.datastatistics.service.ITerminalsMonfreezeDbService;
import com.ruoyi.web.convert.terminalsDayfreezeDb.TerminalsDayfreezeDbConvert;
import com.ruoyi.web.convert.terminalsMonfreezeDb.TerminalsMonfreezeDbConvert;
import com.ruoyi.web.entity.FreezeDay2;
import com.ruoyi.web.entity.FreezeMonth2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 大表日用量数据Controller
 *
 * @author ruoyi
 * @date 2023-09-07
 */
@RestController
@RequestMapping("/api/RealtimeDataStatistic")
public class TerminalsDayfreezeDbController extends BaseController
{
    @Autowired
    private ITerminalsDayfreezeDbService terminalsDayfreezeDbService;

    @Autowired
    private ITerminalsMonfreezeDbService terminalsMonfreezeDbService;

    /**
     * 查询大表日用量数据列表
     * operatorId=24&reportType=3&userTerminalId=628&startTime=2023-12-25%2000%3A00%3A00&endTime=2024-01-24%2023%3A59%3A59&rows=250&page=1
     */
    @GetMapping("/DataAnalysisTerminalsMoreDataList")
    public TableDataInfo list(@RequestParam(value = "startTime",required = false)String startTime,
                              @RequestParam(value = "TerminalID",required = false)String TerminalID,
                              @RequestParam(value = "endTime",required = false)String endTime,
                              @RequestParam(value = "reportType",required = false)String reportType
                              )
    {
        if(reportType.equals("3")){
            startPage();
            List<FreezeDay2> list = TerminalsDayfreezeDbConvert.INSTANCE.convert(terminalsDayfreezeDbService.getTerminalsDayfreezeDbLists(TerminalID,startTime,endTime));
            return getDataTable(list);
        }else if(reportType.equals("4")){
            startPage();
            List<FreezeMonth2> list = TerminalsMonfreezeDbConvert.INSTANCE.convert(terminalsMonfreezeDbService.selectTerminalsMonfreezeDbLists(TerminalID,startTime,
                    endTime));
            return getDataTable(list);
        }else{
            return getDataTable(null);
        }

    }
}
